package com.cskaoyan.market.service;

import com.cskaoyan.market.db.domain.MarketAdmin;
import com.cskaoyan.market.db.domain.MarketAdminExample;
import com.cskaoyan.market.db.domain.MarketOrder;
import com.cskaoyan.market.db.domain.MarketOrderExample;
import com.cskaoyan.market.db.mapper.MarketAdminMapper;
import com.cskaoyan.market.db.mapper.MarketOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class WxUserServiceImpl implements WxUserService{

    @Autowired
    MarketOrderMapper orderMapper;

    /**
     * 待付款：101
     * 待发货：201
     * 待收货：301
     * 待评价：401
     * @return
     */
    @Override
    public Map<String, Object> index(int id) {
        MarketOrderExample orderExample1 = new MarketOrderExample();
        orderExample1.or().andUserIdEqualTo(id).andOrderStatusEqualTo((short)101);
        List<MarketOrder> orders1 = orderMapper.selectByExample(orderExample1);
        MarketOrderExample orderExample2 = new MarketOrderExample();
        orderExample2.or().andUserIdEqualTo(id).andOrderStatusEqualTo((short)201);
        List<MarketOrder> orders2 = orderMapper.selectByExample(orderExample2);
        MarketOrderExample orderExample3 = new MarketOrderExample();
        orderExample3.or().andUserIdEqualTo(id).andOrderStatusEqualTo((short)301);
        List<MarketOrder> orders3 = orderMapper.selectByExample(orderExample3);
        MarketOrderExample orderExample4 = new MarketOrderExample();
        orderExample4.or().andUserIdEqualTo(id).andOrderStatusEqualTo((short)401);
        List<MarketOrder> orders4 = orderMapper.selectByExample(orderExample4);

        Map<String,Object> result = new HashMap<>();
        result.put("unrecv",orders1.size());
        result.put("uncomment",orders2.size());
        result.put("unpaid",orders3.size());
        result.put("unship",orders4.size());

        return result;
    }

}
